Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: long term cache for integer-like PK column in memory #9445

Merged
merged 7 commits into from
Sep 21, 2024

Conversation

Lloyd-Pottiger
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger commented Sep 20, 2024

What problem does this PR solve?

Issue Number: ref #9032

Problem Summary:

What is changed and how it works?

Optimize for VectorDBBench.

  • Cache PK data in memory for queries. Max cache size is 500MB. This avoids IO & decompress repeatedly.
  • Optimize ColumnArray::insertManyDefaults. It is a critical path used in Vector Search, because Vector Search will return sparse results. (TODO: Use ColumnSparse is better)
  • Fix a mistake that previously we build a useless debug string String block_filter_value;, which costs time.
  • Optimize the return filter in Vector Search. Flamegraph shows that BitmapFilter.get() takes time. So this PR totally drops it. DMFileWithVectorIndexBlockInputStream now builds the return filter directly from the result rows.

Benchmark (VectorDBBench, Cohere 1M vectors, 768 dimensions):

Before this PR @ Macbook M1 Pro: 180QPS @ 30 concurrency

output

After this PR @ Macbook M1 Pro: 250QPS @ 30 concurrency

output_5

storage: cache PK column in memory

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 20, 2024
Signed-off-by: Lloyd-Pottiger <[email protected]>
.dmfile_id = dmf_id,
.column_id = column_id,
};
auto [result, _] = cache.getOrSet(key, [&load_fn] { return std::make_shared<IColumn::Ptr>(load_fn()); });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, so it is supported now

Copy link
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Sep 20, 2024
Signed-off-by: Lloyd-Pottiger <[email protected]>
@JaySon-Huang JaySon-Huang changed the title storage: cache PK column in memory storage: long term cache for integer-like PK column in memory Sep 20, 2024
Copy link
Contributor

ti-chi-bot bot commented Sep 21, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: breezewish, CalvinNeo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [CalvinNeo,breezewish]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 21, 2024
Copy link
Contributor

ti-chi-bot bot commented Sep 21, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-20 07:29:41.099539626 +0000 UTC m=+1205450.839963562: ☑️ agreed by CalvinNeo.
  • 2024-09-21 06:31:53.791462941 +0000 UTC m=+1288383.531886882: ☑️ agreed by breezewish.

Copy link
Contributor

ti-chi-bot bot commented Sep 21, 2024

@Lloyd-Pottiger: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

trigger some heavy tests which will not run always when PR updated.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot merged commit 5a41ce2 into pingcap:feature/vector-index Sep 21, 2024
5 of 7 checks passed
@Lloyd-Pottiger Lloyd-Pottiger deleted the cache-pk branch September 22, 2024 12:19
@JaySon-Huang JaySon-Huang mentioned this pull request Sep 30, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants